!(function($){
	"use strict";
	var Page = function() {
		this.$btnSave = $('#btn-save');
	};

	Page.prototype.init = function() {
		this.loadPlugins();
		this.event();
    };
    
    Page.prototype.loadPlugins = function(){
    	$('.ladda-button').ladda();
    },
    
    Page.prototype.event = function(){
    	var $this = this;
    	$this.$btnSave.click(function(){
    		$this.$btnSave.ladda('start');
    		$.ajax({
    			type: 'post',
    			url: contextPath + '/admin/sys/config/add',
    			data: $('#form').serialize(),
    			dataType: 'json',
    			success: function(result){
    				$this.$btnSave.ladda('stop');
    				if(result.success){
    					$.Notification.notify('custom','top center', '通知', '新增成功');
    					setTimeout(() => {
    						window.history.go(-1);
    					}, 1000);
    				} else {
    					$.Notification.notify('error','top center', '通知', result.message);
    				}
    			}
    		});
    	});
    },
   
    // init
	$.Page = new Page, $.Page.Constructor = Page;
})(jQuery);
$(function(){
	$.Page.init();
});

